package com.shop2cn.iapi.prodstockmgr.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.shop2cn.iapi.prodstockmgr.parameter.GetTaskDetailBean;
import com.shop2cn.iapi.prodstockmgr.service.GetTaskDetailCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.Shop2cnStockCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;

/**
 * 查询任务详情Test FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetTaskDetail {
	private static GetTaskDetailBean gettaskdetailBean;
	private static GetTaskDetailCall gettaskdetailCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询任务详情Test");
	}

	@Before
	public void caseUp() {
		gettaskdetailBean = new GetTaskDetailBean();
		gettaskdetailCall = new GetTaskDetailCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(gettaskdetailCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetTaskDetail_001() {
		Logger.start(true, "获取一个导入商品，成功");
		try {
			Integer mchid = GodmchManageCallService.CreateAllMsgSellerMch().getMchId();
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchid,
					"", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Shop2cnStockCallService.AddExportTask(mchid);
			Thread.sleep(2000);
			JsonArray getTaskList = Shop2cnStockCallService.GetTaskList(mchid, 2);
			int taskId = getTaskList.get(0).getAsJsonObject().get("taskId").getAsInt();
			Thread.sleep(1000);
			gettaskdetailBean.setSellerId(mchid);
			gettaskdetailBean.setTaskId(taskId);
			gettaskdetailCall.setData(gettaskdetailBean);
			gettaskdetailCall.callService();
			Logger.verifyEquals("200", gettaskdetailCall.getString("code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}